<?php
/**
* indexController.php
* 管理员主页类 
* @author Yanling
*/
require_once('adminController.php');
class indexController extends adminController {

	/**
	 *@var 白名单
	 *
	 */
	public  $initphp_list = array('login','login_post|post','index|get','logout');
	protected $service_name='index';
	/**
	 *首页
	 *@ type page
	 */
	public function index(){
		$this->doAdminAuth();
		$this->setViewFields();
		$this->view->set_tpl('admin/index');
		$this->view->display();
	}

	/**
	 * 登录页面
	 * @type page
	 */
	public function login(){
		$this->view->set_tpl('admin/login');
		$this->view->display();
	}

	/**
	 *  登录请求
	 *@param $_POST['email']
	 *@param $_POST['password']
	 */
	public function login_post(){
		if(!$this->controller->check_token() ){
			$this->controller->return404() ;
		}
		$admin = $this->controller->get_gp(array('adm_account','adm_password'));
		$admin = $this->adminService->authAdminAccount($admin['adm_account'],$admin['adm_password']);
		
		if($admin){
			$this->adminService->logAdminLoginSession($admin);
			$this->forward('index','index');
		}else{
			$this->tip(array('title'=>'提示','msg'=>'账号密码错误'));	
		}
	}

	/**
	 * 退出
	 *@param 
	 */
	public function logout(){
		$this->adminService->clearAdminLoginSession();		
		$this->forward('index','login');
	}

}